package com.led_on_off.led.slice;

import com.led_on_off.led.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Image;
import ohos.utils.net.Uri;

public class AboutAbilitySlice extends AbilitySlice {
    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_about);

        Image fb = (Image)findComponentById(ResourceTable.Id_facebook);
        Image tweet = (Image)findComponentById(ResourceTable.Id_twitter);
        Image insta = (Image)findComponentById(ResourceTable.Id_instagram);
        Image web = (Image)findComponentById(ResourceTable.Id_website);
        
        fb.setClickedListener(component -> openUri("https://www.facebook.com/mayoogh"));
        tweet.setClickedListener(component -> openUri("https://twitter.com/mayoogh1997/"));
        insta.setClickedListener(component -> openUri("https://www.instagram.com/mayoogh/"));
        web.setClickedListener(component -> openUri("https://mayooghgirish.ml"));
    }

    private void openUri(String s) {
        Intent intent = new Intent();
        intent.setAction("android.intent.action.VIEW");
        Uri uri = Uri.parse("s");
        intent.setUri(uri);
        startAbility(intent);
    }

    @Override
    public void onActive() {
        super.onActive();
    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }


}
